package gzc.xiaonei.service.imp;

import gzc.xiaonei.base.BaseService;
import gzc.xiaonei.model.Users;
import gzc.xiaonei.service.IUserService;

import java.util.List;

@SuppressWarnings("unchecked")
public class UserService extends BaseService implements IUserService {

	/** 验证用户是否存在，返回Users对象，如果返回null,表示该用户不存在 */
	public Users check(Users user) {
		// 通过邮箱和密码查询出用户
		final String hql = "from Users where email=? and pwd=?";
		List<Users> list = super.getResult(hql, new Object[] { user.getEmail(),
				user.getPwd() });
		if (null != list && 1 == list.size()) {
			return list.get(0);
		}
		return null;
	}

}
